; Exercise 1.3
; Deﬁne a procedure that takes three numbers as arguments and returns the sum
; of the squares of the two larger numbers.
;

(define (square x)
  (* x x))

(define (sum-of-squares x y)
  (+ (square x) (square y)))

(define (sum-of-squares-of-two-larger a b c)
  (if (> a b)
    (define loser b)
    (define loser a))
  (if (> a b)
    (define m1 a)
    (define m1 b))
  (if (> loser c)
    (define m2 loser)
    (define m2 c))
  (sum-of-squares m1 m2))

(sum-of-squares-of-two-larger 1 2 3)
(sum-of-squares-of-two-larger 1 3 2)
(sum-of-squares-of-two-larger 2 1 3)
(sum-of-squares-of-two-larger 2 3 1)
(sum-of-squares-of-two-larger 3 2 1)
(sum-of-squares-of-two-larger 3 1 2)


; vim: set lisp expandtabs smarttabs

